package com.cutthroatcreations.woodenrailway;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;

public class LargeImageActivity extends FragmentActivity {
	
	private static String TAG = "LargeImageActivity";
	private ImagePagerAdapter mAdapter;
	private ViewPager mPager;
	private int index;
	public Bitmap bitmap;
	

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.largeimage);
		
		index = getIntent().getIntExtra("index", 1);
		
		mAdapter = new ImagePagerAdapter(getSupportFragmentManager());

		mPager = (ViewPager) findViewById(R.id.pager);
		mPager.setAdapter(mAdapter);
			
	}

	public class ImagePagerAdapter extends FragmentStatePagerAdapter {
		
		public ImagePagerAdapter(FragmentManager fm) {
			super(fm);
			Log.i(TAG, "ImageAdapterCreated");
			
		}

		@Override
		public int getCount() {
			return WoodenApplication.getAllTrains().get(index).images.size();
		}

		
		@Override
		public Fragment getItem(int position) {
			LargeImageFragment frag = new LargeImageFragment();
			Bundle args = new Bundle();
			args.putInt("index", position);
			args.putInt("id", WoodenApplication.getAllTrains().get(index).getID());
			frag.setArguments(args);
			return frag;
		}
	}
	
	
}
